<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <link rel="stylesheet" href="../../css/element.css">
    <link rel="stylesheet" href="../../css/base.css">

    <style>

    </style>
</head>
<body class="frame-body">
<div id="wrapper" v-cloak>
    <el-row style="margin-bottom: 50px" :gutter="20">
        <el-col :span="14" :offset="1">

            <div style="margin: 10px 0">
                <div style="margin: 10px 0">
                    <el-card>
                        <div style="border-bottom: 1px solid orangered; padding: 10px 0; font-size: 20px">法律援助申请进度</div>

                        <el-collapse v-model="activeNames"  @change="handleChange">
                            <el-collapse-item v-for="(application, index) in applications" :key="index" :title="application.caseTitle" :name="index">
                                <h2 style="font-size: 20px">{{ application.caseTitle }}</h2>
                                <el-timeline :reverse="reverse">
                                    <el-timeline-item
                                            v-for="(activity, index) in application.applicationDetailList"
                                            :key="index"
                                            :timestamp="activity.createTime">
                                        <p v-if="application.caseType">案件类型: <b>{{application.caseType}}</b></p>
                                        <p v-if="application.userName">申请人: <b>{{application.userName}}</b></p>
                                        <p v-if="activity.status">审批状态:<b>{{activity.status}}</b></p>
                                        <p v-if="activity.advice">审批意见:<b>{{activity.advice}}</b></p>
                                        <p v-if="activity.userName">审批人:<b>{{activity.userName}}</b></p>
                                        <p v-if="application.lawyerName">援助律师:<b>{{application.lawyerName}}</b></p>

                                    </el-timeline-item>
                                </el-timeline>
                            </el-collapse-item>
                        </el-collapse>
                    </el-card>
                </div>
            </div>

        </el-col>

        <el-col :span="6" :offset="1">
            <div style="margin: 10px 0">
                <el-card class="box-card">
                    <h2>申请记录</h2>
                    <br>
                    <div v-for="(application,index) in applications" :key="index" class="text item">
                        <h3>【{{application.caseType}}】{{'案件标题: ' + application.caseTitle }}-----{{'状态: '+application.status}}</h3>
                    </div>
                </el-card>
            </div>
        </el-col>
    </el-row>



</div>

<!--    js-->
<script src="../../js/jquery.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/element.js"></script>

<script>
    new Vue({
        el: "#wrapper",
        data: {
            src: 'message.html',
            search: '',
            tableData: [],
            pageNum: 1,
            pageSize: 10,
            total: 0,
            user: {},
            activeNames: ['1'],
            applications:[],
            activities: [{
                content: '活动按期开始',
                timestamp: '2018-04-15'
            }, {
                content: '通过审核',
                timestamp: '2018-04-13'
            }, {
                content: '创建成功',
                timestamp: '2018-04-11'
            }],
            reverse: false,
        },
        created() {
            $.ajax({url: '/api/user/session', method: "GET", async: false, success: (res) => {this.user = res.data || {}}})
            this.loadTable()
        },
        methods: {
            sign(obj) {

            },
            logout() {
                $.get("/api/user/logout");
                sessionStorage.removeItem("user");
                location.href = "/page/end/login.html";
            },
            loadTable() {
                if(!this.user.id) {
                    this.$message({
                        message: "请登录！",
                        type: "warning"
                    })
                    return
                }
                $.get("/api/user/" + this.user.id).then(res => {
                    this.user = res.data
                })
                $.get("/api/applications/currentUser").then(res =>{
                    console.log("res.data",res.data)
                    this.applications = res.data
                })
            },
            handleSizeChange(pageSize) {
                this.pageSize = pageSize;
                this.loadTable();
            },
            handleCurrentChange(pageNum) {
                this.pageNum = pageNum;
                this.loadTable();
            },
            handleChange(val) {
                console.log(val);
            },
        }
    })
</script>
</body>
</html>
